package com.study.juc.threadpool;

public interface DenyPolicy {
    
    void reject(Runnable runnable,ThreadPool pool);
    
    
    class DiscardDenyPolicy implements  DenyPolicy{
        @Override
        public void reject(Runnable runnable, ThreadPool pool) {
            
        }
    }
    
    class AbortDenyPolicy implements DenyPolicy{
        @Override
        public void reject(Runnable runnable, ThreadPool pool) {
            throw new RuntimeException();
        }
    }
    
    class RunnableDenyPolicy implements DenyPolicy{
        @Override
        public void reject(Runnable runnable, ThreadPool pool) {
            if(!pool.isShutDown()){
                runnable.run();
            }
        }
    }
    
}
